Skip to content

feat: add expect "..." by print ... command#986

Merged
strub merged 1 commit intomainfrom
feat-expect-output
Apr 23, 2026
Merged

feat: add expect "..." by print ... command#986
strub merged 1 commit intomainfrom
feat-expect-output

Conversation

@strub
Copy link
Copy Markdown
Member

@strub strub commented Apr 23, 2026

Summary

Adds a top-level EasyCrypt command for unit-testing pretty-printer
output from inside .ec files:

expect "op foo : int = 1." by print op foo.

The expected string is compared against the captured output of the
inner print command (trimmed on both sides). On mismatch, an
hierror is raised — this fails the enclosing script in the standard
way and is picked up by scripts/testing/runtest.

Multi-line expected literals are supported out of the box because the
existing STRING lexer rule already accepts embedded newlines.

Known limitations / possible follow-ups

  • Only print is supported as the inner command; search/locate could be added trivially.
  • Comparison is String.trim-based: leading/trailing whitespace tolerant, strict on internal whitespace. A stricter/normalized mode could be added.
  • No --promote-expect auto-update workflow yet (design discussed, deferred).

Introduce a top-level command for unit-testing pretty-printer output
from inside `.ec` files:

    expect "op foo : int = 1." by print op foo.

The expected string is compared (after `String.trim` on both sides)
against the captured output of the inner `print` command. On mismatch,
raise an `hierror` with the expected and actual blocks; this fails the
enclosing script in the standard way and is picked up by `scripts/testing/runtest`.

Multi-line expected literals are supported out of the box because the
existing STRING lexer rule already accepts embedded newlines.

Also adds tests/expect.ec covering nullary/parametric ops, record
types, axioms, and leading/trailing whitespace tolerance.
@strub strub self-assigned this Apr 23, 2026
@strub strub added chore Ungrateful tasks that need done but that nobody wants to do feature labels Apr 23, 2026
Comment thread src/ecParser.mly
@strub strub added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit e74c002 Apr 23, 2026
16 checks passed
@strub strub deleted the feat-expect-output branch April 23, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Ungrateful tasks that need done but that nobody wants to do feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants